<template>
  <div class="otherHome">
    <Other-Header bgColor="#5741d9"></Other-Header>
    <div class="newbieGuideBox">
      <!-- 面包屑crumbs-->
      <el-breadcrumb separator-class="el-icon-arrow-right">
        <el-breadcrumb-item :to="{ path: '/' }">{{$t('l.home')}}</el-breadcrumb-item>
        <el-breadcrumb-item
          :to="{ path: '/announcement', query: {type: type} }"
        >{{type==0?$t('l.other_a_0'):$t('l.other_a_4')}}</el-breadcrumb-item>
        <el-breadcrumb-item>{{categoryName}}</el-breadcrumb-item>
      </el-breadcrumb>
      <!-- 标题 -->
      <div class="newbieGuide">
        <div class="termsInfo">
          <div class="termsInfoSearch">
            <el-input
              :placeholder="$t('l.other_a_63')"
              suffix-icon="el-icon-search"
              size="small"
              style="width: 240px;"
            ></el-input>
          </div>
          <div class="advertBox">
            <i></i>
            <h3 class="advertTitle">{{categoryName}}</h3>
          </div>
        </div>
        <!-- 内容 -->
        <div class="newbieGuideCon">
          <ul class="newbieGuideList">
            <li
              class="newbieGuideItem"
              v-for="(item,index) in items"
              :key="index"
              @click="linkDetailPage(item.id, type, typeCode)"
            >
              <span>{{item.createTime}}</span>
              <p>{{item.title}}</p>
            </li>
          </ul>
          <div class="transPages">
            <el-pagination
              v-show="hasPagination"
              background
              layout="prev, pager, next"
              :page-count="pageCount"
              @current-change="onCurrentChange"
            ></el-pagination>
          </div>
        </div>
      </div>
    </div>
    <Footer></Footer>
  </div>
</template>

<script>
import { api } from "@/api/api";
import OtherHeader from "@/components/otherHeader";
import Footer from "@/components/footer";
export default {
  components: {
    OtherHeader,
    Footer
  },
  data() {
    return {
      type: 0,
      typeCode: "",
      categoryName: "",
      termsInfoInput: "",
      items: [],
      hasPagination: false,
      pageNum: 1,
      pageCount: 1 // 总页数
    };
  },
  async created() {
    let { type, typeCode } = this.$route.query;

    this.type = type;
    this.typeCode = typeCode;
    this.getAnnouncementList();
  },
  methods: {
    linkDetailPage(articleId, type, typeCode) {
      this.$router.push({
        path: "/articleDetails",
        query: {
          articleId
        }
      });
    },
    onCurrentChange(pageNum) {
      this.pageNum = pageNum;
      this.getAnnouncementList();
    },
    // 获取公告和问题列表
    async getAnnouncementList() {
      let params = {
        lang: "zh_CN",
        pageNum: this.pageNum,
        pageSize: 15,
        typeCode: this.typeCode
      };
      let res = await api.announcementList(params);
      let { code, data, msg } = res.data;

      if (code == 0) {
        let { records, pages } = data;

        this.items = records;

        if (data.records[0]) {
          this.categoryName = data.records[0].categoryName;
        }

        this.pageCount = pages;
        this.hasPagination = this.pageCount > 1;
      } else {
        this.pageCount = 0;
        this.hasPagination = false;
        this.$layer.msg(msg);
      }
    }
  }
};
</script>

<style lang="less" scoped>
.otherHome {
  background-color: #f7f8fc;
  position: absolute;
  min-height: 100%;
  width: 100%;
  padding-top: 100px;
}
.newbieGuideBox {
  width: 1200px;
  box-sizing: border-box;
  overflow: auto;
  margin: 0 auto;
  padding-bottom: 160px;

  /* 面包屑 */
  /deep/.el-breadcrumb__inner a,
  /deep/.el-breadcrumb__inner.is-link {
    height: 60px;
    line-height: 60px;
    font-size: 16px;
    font-familyA: PingFangSC-Regular;
    font-weight: 400;
    color: rgba(51, 56, 94, 0.5);
  }
  /deep/span.el-breadcrumb__item:last-child span {
    height: 60px;
    line-height: 60px;
    font-size: 16px;
    font-familyA: PingFangSC-Regular;
    font-weight: 400;
    color: #2D8DFE;
  }
  /* 内容 */
  .newbieGuide {
    width: 1200px;
    min-height: 790px;
    background: rgba(255, 255, 255, 1);
    padding: 36px 40px 80px;
    box-sizing: border-box;
    .advertBox {
      position: relative;
      overflow: hidden;
      .advertTitle {
        display: inline-block;
        font-size: 24px;
        font-familyA: PingFangSC-Semibold;
        font-weight: 600;
        color: rgba(51, 56, 94, 1);
        line-height: 33px;
        margin-left: 20px;
        vertical-align: top;
      }
      i {
        position: absolute;
        width: 3px;
        height: 16px;
        background: #2D8DFE;
        border-radius: 2px;
        color: #33385e;
        top: 50%;
        transform: translateY(-50%);
        -webkit-transform: translateY(-50%);
      }
    }
    .termsInfoSearch {
      float: right;
    }
    .newbieGuideCon {
      margin-top: 24px;
      overflow: hidden;
      padding-left: 20px;
      .newbieGuideList {
        .newbieGuideItem {
          overflow: hidden;
          // margin-bottom: 35px;
          padding: 16px 0;
          border-bottom: 1px solid #f0f2fd;
          cursor: pointer;
          p {
            font-size: 14px;
            font-familyA: PingFangSC-Regular;
            font-weight: 400;
            color: rgba(51, 56, 94, 1);
            line-height: 20px;
          }
          span {
            float: right;
            font-size: 14px;
            font-familyA: PingFangSC-Regular;
            font-weight: 400;
            color: rgba(51, 56, 94, 1);
            line-height: 20px;
          }
        }
      }
    }
  }
}
.transPages {
  margin-top: 40px;
  margin-bottom: 30px;
  width: 100%;
  text-align: center;
}
</style>